# Huawei Technologies Co.,Ltd.

set(GENERATOR_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generator.txt)
set(GENERATOR_BIN ${CMAKE_CURRENT_BINARY_DIR}/generator.abc)
set(GENERATOR_JS ${CMAKE_CURRENT_SOURCE_DIR}/generator.js)
set(GENERATOR_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${GENERATOR_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${GENERATOR_OUTPUT}
    COMMENT "running javascript generator testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${GENERATOR_JS} --output ${GENERATOR_BIN}
    COMMAND rm -f ${GENERATOR_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} 2>&1 > ${GENERATOR_OUTPUT}
    COMMAND bash ${GENERATOR_VERIFY} ${GENERATOR_OUTPUT}
)
add_custom_target(generator
        DEPENDS ${GENERATOR_OUTPUT} ${GENERATOR_VERIFY}
        )
add_dependencies(generator ark_asm ark)
add_dependencies(ecmascript_common_tests generator)
